#include <stdio.h>
#include <math.h>
#include <map>
#include <list>
#include <stdlib.h>
using namespace std;

#define TRACE(x...) 
#define PRINT(x...) TRACE(printf(x))
#define PR 1000000
#define SQRTPR 1000

int x, d;
int a, b;
bool primes[1000010];
int _42;
map<int, int> mA;
map<int, int> mB;
int tmpA;
int tmpB;

void sieve() {
	int p=2;

	for (int i=0; i<PR; i++) primes[i]=true;

	while (p<=SQRTPR) {
		for (int i=p; (i*p)<=PR; i++)
			primes[i*p]=false;

		while (!primes[++p]);
	}

	/*TRACE(
		for (int i=2; i<=PR; i++)
			if (primes[i]) printf("%d ", i);

		printf("\n");
	)*/
}

list<int> unio;

int main() {
	_42=0;
	sieve();
		
	while (1) {
		_42++; mA.clear(); mB.clear();
		unio.clear();
		scanf("%d %d", &a, &b);
		
		if (!a && !b) break;
		tmpA=a; tmpB=b;	
	

		for (int i=2; i<=a; i++) {
			while (tmpA%i==0 && primes[i]) {
				if (mA.find(i)==mA.end()) {
					mA[i]=1;
					unio.push_back(i);
				}
				else mA[i]++;
				
				tmpA/=i;
			}
		}
		
		for (int i=2; i<=b; i++) {
			while (tmpB%i==0 && primes[i]) {
				if (mB.find(i)==mB.end()) {
					mB[i]=1;
					unio.push_back(i);
				}
				else mB[i]++;
			
				tmpB/=i;
			}
		}

		TRACE(
			printf("For a: ");
			for (map<int, int>::iterator it=mA.begin(); it!=mA.end(); it++)
				printf("%d^%d ",it->first, it->second);
			printf("\n");

			printf("For b: ");
			for (map<int, int>::iterator it=mB.begin(); it!=mB.end(); it++)
				printf("%d^%d ",it->first, it->second); 
			printf("\n");
		); 
		unio.sort();
		unio.unique();

		printf("%d. ", _42);
		printf("%d:", unio.size());

		int dist=0;

		for (list<int>::iterator it=unio.begin(); it!=unio.end(); it++) {
			if (mA.find(*it)==mA.end()) dist+=mB[*it];
			else if (mB.find(*it)==mB.end()) dist+=mA[*it];
			else dist += abs(mA[*it]-mB[*it]);
		}

		printf("%d\n", dist);


	}

	return 0;
}
